package demo09;

public class MyStringTest {public static void main(String[] args) {

    String str1 = "hello java";

    String str2 = "hello java";

    if (str1.equals(str2)) {

        String strWithoutSpaces = str1.replaceAll("\\s", "");

        String replacedStr = strWithoutSpaces.replace("java", "word");


        System.out.println("去掉空格后的字符串: " + strWithoutSpaces);

        System.out.println("替换'java'为'word'后的字符串: " + replacedStr);

    } else {

        System.out.println("两个字符串不相等");
    }

}

}

